package com.niodata.dp.monitor.core.task;

import java.util.LinkedHashMap;
import java.util.Map;

public class LruCache<K, V> extends LinkedHashMap<K, V> {

  private int size;

  private LruCache(int size) {
    super(size, 0.75f, true);
    this.size = size;
  }

  public static <K, V> LruCache<K, V> newInstance(int size) {
    return new LruCache<K, V>(size);
  }

  @Override
  protected boolean removeEldestEntry(Map.Entry<K, V> eldest) {
    return size() > size;
  }


}
